package com.vvv.config;

import com.vvv.constants.RabbitMQConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author vvv
 * @date 2023-12-08 15 59
 * discription
 */
@Configuration
public class MqConfig {

    @Bean
    public Queue grabbingQueue() {
        return new Queue(RabbitMQConstant.GRABBING_QUEUE_NAME);
    }

    @Bean
    public Queue droppingQueue() {
        return new Queue(RabbitMQConstant.DROPPING_QUEUE_NAME);
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(RabbitMQConstant.COURSE_EXCHANGE_NAME);
    }

    @Bean
    public Binding bindingQueue(Queue grabbingQueue, DirectExchange directExchange){
        return BindingBuilder.bind(grabbingQueue).to(directExchange)
                .with(RabbitMQConstant.GRABBING_ROUTING_KEY);
    }

    @Bean
    public Binding bindingQueue2(Queue droppingQueue, DirectExchange directExchange){
        return BindingBuilder.bind(droppingQueue).to(directExchange)
                .with(RabbitMQConstant.DROPPING_ROUTING_KEY);
    }
}
